package com.frank.lzda.zfqd.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.frank.common.annotation.Log;
import com.frank.common.enums.BusinessType;
import com.frank.lzda.zfqd.domain.LzdaZfqd;
import com.frank.lzda.zfqd.service.ILzdaZfqdService;
import com.frank.common.core.controller.BaseController;
import com.frank.common.core.domain.AjaxResult;
import com.frank.common.utils.poi.ExcelUtil;
import com.frank.common.core.page.TableDataInfo;

/**
 * 政法各单位清单Controller
 * 
 * @author frank
 * @date 2025-04-07
 */
@Controller
@RequestMapping("/lzda/zfqd")
public class LzdaZfqdController extends BaseController
{
    private String prefix = "lzda/zfqd";

    @Autowired
    private ILzdaZfqdService lzdaZfqdService;

    @RequiresPermissions("lzda:zfqd:view")
    @GetMapping()
    public String zfqd()
    {
        return prefix + "/zfqd";
    }

    /**
     * 查询政法各单位清单列表
     */
    @RequiresPermissions("lzda:zfqd:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(LzdaZfqd lzdaZfqd)
    {
        lzdaZfqd.setCreateBy(getLoginName());
        startPage();
        List<LzdaZfqd> list = lzdaZfqdService.selectLzdaZfqdList(lzdaZfqd);
        return getDataTable(list);
    }

    /**
     * 导出政法各单位清单列表
     */
    @RequiresPermissions("lzda:zfqd:export")
    @Log(title = "政法各单位清单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(LzdaZfqd lzdaZfqd)
    {
        List<LzdaZfqd> list = lzdaZfqdService.selectLzdaZfqdList(lzdaZfqd);
        ExcelUtil<LzdaZfqd> util = new ExcelUtil<LzdaZfqd>(LzdaZfqd.class);
        return util.exportExcel(list, "zfqd");
    }

    /**
     * 新增政法各单位清单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存政法各单位清单
     */
    @RequiresPermissions("lzda:zfqd:add")
    @Log(title = "政法各单位清单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(LzdaZfqd lzdaZfqd)
    {
        lzdaZfqd.setCreateBy(getLoginName());
        return toAjax(lzdaZfqdService.insertLzdaZfqd(lzdaZfqd));
    }

    /**
     * 修改政法各单位清单
     */
    @RequiresPermissions("lzda:zfqd:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        LzdaZfqd lzdaZfqd = lzdaZfqdService.selectLzdaZfqdById(id);
        mmap.put("lzdaZfqd", lzdaZfqd);
        return prefix + "/edit";
    }

    /**
     * 修改保存政法各单位清单
     */
    @RequiresPermissions("lzda:zfqd:edit")
    @Log(title = "政法各单位清单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(LzdaZfqd lzdaZfqd)
    {
        lzdaZfqd.setUpdateBy(getLoginName());
        return toAjax(lzdaZfqdService.updateLzdaZfqd(lzdaZfqd));
    }

    /**
     * 删除政法各单位清单
     */
    @RequiresPermissions("lzda:zfqd:remove")
    @Log(title = "政法各单位清单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(lzdaZfqdService.deleteLzdaZfqdByIds(ids));
    }
}
